/**
 * 广告图
 * Created by levy on 16/6/3.
*/
import RichText from '../components/RichText.js';

{
    var lf = liefeng,
        id = lf.utils.getUrlParam('id');

    var Root = React.createClass({
        getInitialState() {
            return {
                text: '',
            }
        },

        componentWillMount() {
            var me = this;

            lf.utils.ajax({
                data: {
                    projectId: this.props.user.projectId,
                }
            },lf.finger.api.homeImages, function (data) {
                $.each(data, function (i, item) {
                    if(item.id == id) {
                        me.setState({text: item.imageContent});
                    }
                });
            });
        },

        render() {
            return <RichText text={this.state.text}/>
        }
    });

    lf.bridgeJs.getUser(function (user) {
        React.render(
            <Root user={user}/>,
            document.getElementById('root'), function () {
            }
        );
    });
}
